/**
 * 
 */
package com.star.page;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.github.miemiedev.mybatis.paginator.domain.Paginator;

/**
 * @ClassName: PageListToMap
 * @Description: 为了让fastjson能序列化pagelist，写了此类 这个方法不好，以后要想办法自定义序列化方法 要配合分页组件
 * @author starhq
 * @createtime 2014年9月8日 下午3:27:06
 * @email : jian.wang@shinsoft.net
 * @modify by TODO
 * @resaon
 * @edittime
 * @version 1.0
 * @copyright shinsoft
 */
public class PageListToMap {

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static Map<String, Object> convert(PageList value) {
		Map<String, Object> map = new HashMap<String, Object>();
		Paginator paginator = value.getPaginator();
		map.put("totalCount", paginator.getTotalCount());
		map.put("totalPages", paginator.getTotalPages());
		map.put("page", paginator.getPage());
		map.put("limit", paginator.getLimit());
		map.put("items", new ArrayList(value));

		map.put("startRow", paginator.getStartRow());
		map.put("endRow", paginator.getEndRow());

		map.put("offset", paginator.getOffset());

		map.put("slider", paginator.getSlider());

		map.put("prePage", paginator.getPrePage());
		map.put("nextPage", paginator.getNextPage());

		map.put("firstPage", paginator.isFirstPage());
		map.put("hasNextPage", paginator.isHasNextPage());
		map.put("hasPrePage", paginator.isHasPrePage());
		map.put("lastPage", paginator.isLastPage());

		return map;
	}
}
